package com.gitee.somenvm.ninerpgitem.core.command


import com.gitee.somenvm.ninerpgitem.ConfigManager
import com.gitee.somenvm.ninerpgitem.api.event.plugin.NineRpgItemReloadEvent
import org.bukkit.command.CommandSender
import taboolib.common.platform.command.CommandBody
import taboolib.common.platform.command.CommandHeader
import taboolib.common.platform.command.mainCommand
import taboolib.common.platform.command.subCommand
import taboolib.expansion.createHelper
import taboolib.platform.util.sendLang


@CommandHeader(
    name = "ninerpgitem",
    aliases = ["nri", "nrpg", "nine"],
    permission = "ninerpgitem.main"
)
object MainCommand {
    @CommandBody
    val main = mainCommand {
        createHelper()
    }

    @CommandBody
    val reload = subCommand {
        execute<CommandSender> { sender, _, _ ->
            ConfigManager.reload()
            NineRpgItemReloadEvent.Template().call()
            NineRpgItemReloadEvent.Item().call()
            NineRpgItemReloadEvent.Config().call()
            NineRpgItemReloadEvent.Forge().call()
            NineRpgItemReloadEvent.Inlay().call()
            NineRpgItemReloadEvent.Recast().call()
            sender.sendLang("reload")
        }
    }

    @CommandBody
    val item = ItemCommand

    @CommandBody
    val test = TestCommand


}